package com.example.demo.controller;

import com.example.demo.common.Result;
import com.example.demo.dao.UserDb;
import com.example.demo.entity.User;
import com.example.demo.service.UserServiceImpl;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

@RestController
@RequestMapping("/auth")
public class LoginController {
    @Autowired
    private UserServiceImpl userService;
    @PostMapping("/register/")
    public Result register(@RequestBody User user){
        userService.add(user);
        System.out.println(user);
        return Result.success();
    }
    @PostMapping("/login/")
    public Result submitUserForm(@RequestBody User user) {
        User loginuser = userService.login(user);
        System.out.println(userService);
        return Result.success(loginuser);
    }
}
